home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / long.h < prev    next >
C/C++ Source or Header  |  2000-01-06  |  5KB  |  148 lines

  1. // $Id: long.h,v 1.7 2000/01/06 06:46:47 lord Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef Long_INCLUDED
  11. #define Long_INCLUDED
  12.  
  13. #include "config.h"
  14. #include <math.h>
  15.  
  16. class IEEEdouble;
  17. class IEEEfloat;
  18.  
  19. class LongInt;
  20. class ULongInt;
  21.  
  22. class BaseLong
  23. {
  24. protected:
  25.     union
  26.     {
  27.         double double_words;
  28.         u4 word[2];
  29.     } value;
  30.  
  31. #ifdef WORDS_BIGENDIAN
  32.     u4 &High() { return value.word[0]; }
  33.     u4 &Low()  { return value.word[1]; }
  34. #else
  35.     u4 &Low()  { return value.word[0]; }
  36.     u4 &High() { return value.word[1]; }
  37. #endif
  38.  
  39. public:
  40.  
  41.     u4 HighWord() { return High(); }
  42.     u4 LowWord()  { return Low(); }
  43.  
  44.     double DoubleView() { return value.double_words; }
  45.  
  46.     BaseLong(u4 a, u4 b);
  47.     BaseLong(u4 a);
  48.     BaseLong(i4 a);
  49.     inline BaseLong (void) {}
  50.  
  51.     BaseLong  operator+  (BaseLong); // binary addition
  52.     BaseLong  operator+  ();         // unary plus
  53.     BaseLong& operator+= (BaseLong); // add and assign
  54.     BaseLong  operator++ (int);      // postfix increment
  55.     BaseLong  operator++ ();         // prefix increment
  56.  
  57.     BaseLong  operator-  (BaseLong); // binary subtraction
  58.     BaseLong  operator-  ();         // unary minus
  59.     BaseLong& operator-= (BaseLong); // subtract and assign
  60.     BaseLong  operator-- (int);      // postfix decrement
  61.     BaseLong  operator-- ();         // prefix decrement
  62.  
  63.     BaseLong  operator* (BaseLong);  // multiplication
  64.     BaseLong& operator*=(BaseLong);  // multiply and assign
  65.  
  66.     BaseLong  operator<< (BaseLong); // left shift
  67.     BaseLong& operator<<=(BaseLong); // left shift and assign
  68.  
  69.     bool      operator== (BaseLong); // equal
  70.     bool      operator!= (BaseLong); // not equal
  71.     bool      operator!  ();         // logical complement
  72.  
  73.     BaseLong  operator~  ();         // bitwise complement
  74.     BaseLong  operator^  (BaseLong); // bitwise XOR
  75.     BaseLong& operator^= (BaseLong); // bitwise XOR and assign
  76.     BaseLong  operator|  (BaseLong); // bitwise OR
  77.     BaseLong& operator|= (BaseLong); // bitwise OR and assign
  78.     BaseLong  operator&  (BaseLong); // bitwise AND
  79.     BaseLong& operator&= (BaseLong); // bitwise AND and assign
  80.  
  81.     bool      operator&& (BaseLong); // logical AND (not short-circuit)
  82.     bool      operator|| (BaseLong); // logical OR (not short circuit)
  83.  
  84.     static void Divide(BaseLong, BaseLong, BaseLong &, BaseLong &);
  85.  
  86.     operator LongInt();                 // Cast to LongInt
  87.     operator ULongInt();                // Cast to ULongInt
  88. };
  89.  
  90.  
  91. class LongInt : public BaseLong
  92. {
  93. public:
  94.  
  95.     inline LongInt (u4 a, u4 b) : BaseLong (a, b) {}
  96.     inline LongInt (u4 a) : BaseLong (a) {}
  97.     inline LongInt (i4 a) : BaseLong (a) {}
  98.     inline LongInt (void) : BaseLong () {}
  99.     LongInt (IEEEdouble) ; //BaseLong (a) {};
  100.     LongInt (IEEEfloat) ; //BaseLong (a) {};
  101.  
  102.     LongInt  operator/  (LongInt); // divide
  103.     LongInt& operator/= (LongInt); // divide and assign
  104.  
  105.     LongInt  operator%  (LongInt); // modulus
  106.     LongInt& operator%= (LongInt); // modulus and assign
  107.  
  108.     LongInt  operator>> (LongInt); // right shift
  109.     LongInt& operator>>=(LongInt); // right shift and assign
  110.  
  111.     bool  operator<  (LongInt); // less-than
  112.     bool  operator>  (LongInt); // greater-than
  113.     bool  operator<= (LongInt); // less-than or equal
  114.     bool  operator>= (LongInt); // greater-than or equal
  115.  
  116.     double Double();           // convert ULongInt value to a double value
  117. };
  118.  
  119.  
  120. class ULongInt : public BaseLong
  121. {
  122. public:
  123.  
  124.     inline ULongInt (u4 a, u4 b) : BaseLong (a, b) {}
  125.     inline ULongInt (u4 a) : BaseLong (a) {}
  126.     inline ULongInt (i4 a) : BaseLong (a) {}
  127.     inline ULongInt (void) : BaseLong () {}
  128.  
  129.     ULongInt  operator/  (ULongInt); // divide
  130.     ULongInt& operator/= (ULongInt); // divide and assign
  131.  
  132.     ULongInt  operator%  (ULongInt); // modulus
  133.     ULongInt& operator%= (ULongInt); // modulus and assign
  134.  
  135.     ULongInt  operator>> (ULongInt); // right shift
  136.     ULongInt& operator>>=(ULongInt); // right shift and assign
  137.  
  138.     bool   operator<  (ULongInt); // less-than
  139.     bool   operator>  (ULongInt); // greater-than
  140.     bool   operator<= (ULongInt); // less-than or equal
  141.     bool   operator>= (ULongInt); // greater-than or equal
  142.  
  143.     double Double();      // convert LongInt value to a double value
  144. };
  145.  
  146.  
  147. #endif
  148.